package com.itheima.zixi3.ZuoYe2;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Test {
    public static void main(String[] args) {
        Stu s1 = new Stu("张三", 22);
        Stu s2 = new Stu("李四", 26);
        Stu s3 = new Stu("张翠山", 38);
        Stu s4 = new Stu("赵六", 19);
        Stu s5 = new Stu("张三丰", 103);
        Stu s6 = new Stu("张wuji", 17);
        Stu s7 = new Stu("赵敏", 16);
        Stu [] names = {s1,s2,s3,s4,s5,s6,s7};
        Collection<Stu> c = new ArrayList<Stu>();
        for (int i = 0; i < names.length; i++) {
            c.add(names[i]);
        }
        Iterator<Stu> i = c.iterator();
        while (i.hasNext()) {
            Stu s = i.next();
            if(s.getName().startsWith("张")&&s.getAge() >= 18){
                System.out.println(s.getName() + " " + s.getAge());
            }
        }
    }
}
